home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / Dreamweaver 3 / slices.htt < prev   
Encoding:
Text File  |  1999-11-19  |  32.1 KB  |  1,037 lines

  1. // Fireworks Dreamweaver 3.0 HTML & JavaScript for sliced output.
  2. // Version 3.0 04AUG99
  3.  
  4.  
  5. // To export HTML without comments change the value of variable doComments to "false".
  6. var doComments = true;
  7.  
  8. // These are the suffixes for the first 4 frames
  9. var sfx = new Array();
  10. sfx[0] = "";        // first frame doesn't normally have a suffix.
  11. sfx[1] = "_f2";        // second frame.
  12. sfx[2] = "_f3";        // third frame.
  13. sfx[3] = "_f4";        // fourth frame.
  14. var numSFX = 4;
  15. function UpdateFileNames(curSlices) {
  16.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  17.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  18.             if (curSlices[curRow][curCol].skipCell) continue;
  19.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  20.             if (nestedTable) {
  21.                 UpdateFileNames(nestedTable);
  22.                 continue;
  23.             }
  24.             var curSlice = curSlices[curRow][curCol];
  25.             var cellName = "";
  26.             if (curSlice && curSlice.getFrameFileName(0)) {
  27.                 cellName = curSlice.getFrameFileName(0).toString();
  28.                 var i;
  29.                 var limit = exportDoc.numFrames;
  30.                 if (limit > numSFX) limit = numSFX;
  31.                 for (i=0; i<limit; i++) {
  32.                     if (curSlice.getFrameFileName(i)) {
  33.                         curSlice.setFrameFileName(i, cellName + sfx[i]);
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
  40. UpdateFileNames(slices);
  41.  
  42. var doHeader = true;
  43. doHeader = exportDoc.generateHeader; 
  44. if (!doHeader) doComments = false;
  45. // When HTML is generated to a file, generateHeader is true.
  46. // When HTML is generated for the clipboard, (or DW3 metafile) 
  47. // generateHeader is false.
  48.  
  49. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  50. // include HTML and JavaScript comments in the exported file.
  51. function WRITE_HTML_COMMENT(str) {
  52.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  53. }
  54.  
  55. function WRITE_JS_COMMENT(str) {
  56.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  57. }
  58.  
  59. // Declare variables for processing Behaviors.    
  60. var kActionStatusMessage = 1;
  61. var kActionSwapImage = 2;
  62. var kActionButtonDown = 4;
  63. var kActionSwapImageRestore = 5;
  64. var kActionButtonHighlight = 6; 
  65. var kActionButtonRestore = 7;
  66.  
  67. var kEventMouseOver = 0;
  68. var kEventOnClick = 1;
  69. var kEventMouseOut = 2;
  70. var kEventOnLoad = 3;
  71.  
  72. var hasStatusMessage = false;
  73. var hasSwap = false;
  74. var hasDown = false;
  75. var hasRestore = false;
  76.  
  77.  
  78. if (doHeader) {
  79.     // Write general comments for copying and pasting Fireworks-generated code into existing HTML documents.
  80.     WRITE_HTML_COMMENT("To put this html into an existing HTML document, you must copy the JavaScript and");
  81.     WRITE_HTML_COMMENT("paste it in a specific location within the destination HTML document. You must then copy");
  82.     WRITE_HTML_COMMENT("and paste the table in a different location.");
  83.     WRITE_HTML("\n");
  84.  
  85.     WRITE_HTML("<html>\n");
  86.  
  87.     WRITE_HTML("<head>\n");
  88.  
  89.     // Use Base Name from export dialog as document title.
  90.     WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  91.  
  92.     // Write Meta tags.
  93.     WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  94.     var charSet = App.getPref("HtmlCharSet");
  95.     if (charSet == "") charSet = "iso-8859-1";
  96.     WRITE_HTML(charSet + "\">\n"); 
  97.     WRITE_HTML("<meta name=\"description\" content=\"Fireworks Splice HTML\">\n");
  98. }
  99.  
  100. // Write HTML target and date created.
  101. var d = new Date();
  102. WRITE_HTML("<!-- Fireworks 3.0  Dreamweaver 3.0 target.  Created ", d, " -->\n");
  103. WRITE_HTML("\n");
  104.  
  105. // Function cellName determines the name for the image in a particular table cel
  106. // cellName is based off of the slice name if one was specified. Otherwise the
  107. // Base file name from the export dialog is used.
  108. function CellName(curSlices, row, col) {
  109.     var curSlice = curSlices[row][col];
  110.     var cellName = "";
  111.     if (curSlice && curSlice.getFrameFileName(0)) {
  112.         cellName = curSlice.getFrameFileName(0).toString();
  113.         curSlice.setFrameFileName(0, cellName);
  114.         // remove illegal characters
  115.         cellName = cellName.replace(/\W/g, "");
  116.         // if it starts with a number, add N to the front.
  117.         if (cellName == "") cellName = "n" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  118.         if (cellName.search(/\d/) == 0) {
  119.             cellName = "n"+cellName;
  120.         }
  121.     }
  122.     if (cellName!="") return(cellName);     
  123.  
  124.     var prefix;
  125.     if (!curSlices) return("nullCellName");
  126.     if (curSlices.id == 0) {
  127.         prefix = "";
  128.     } else {
  129.         prefix = curSlices.id+"_";
  130.     }
  131.     var suffix="";
  132.     if (curSlices.numRows > 1 || curSlices.numColumns > 1) {
  133.         suffix = "_" + (row+1) + "_" + (col+1);
  134.     }
  135.     cellName = "n" + prefix + exportDoc.imagename + suffix;
  136.     return(cellName);
  137. }
  138.  
  139. // Determine and process Behaviors in the document.
  140. function ProcessEvent(theCurBehaviors, targetEvent) {
  141.     // Declare variable for processing Behaviors.
  142.     var javaScript = "";
  143.     var stat = false;
  144.     var eraseStatOnMouseOut = false;
  145.     var swapImage = "";
  146.     var nbHighlight = "";
  147.     var nbHighlightPreload = false;
  148.     var nbDown = "";
  149.     var nbDownPreload = false;
  150.     var swap = "";
  151.     var swapRestore = false;
  152.     var buttonRestore = false;
  153.     
  154.     // Translate Behaviors into JavaScript.
  155.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  156.         curBehavior = theCurBehaviors[i];
  157.         
  158.         if (curBehavior.ignoreFlag) continue;
  159.         // Check for erase on mouse out status messages.
  160.         if (curBehavior.action == kActionStatusMessage) {
  161.             if (curBehavior.restoreOnMouseout) eraseStatOnMouseOut=true;
  162.         }
  163.         
  164.         if (curBehavior.event != targetEvent) continue;
  165.         
  166.         if (curBehavior.action == kActionStatusMessage) {
  167.             var statMsg = curBehavior.statusText;
  168.             var curStat = "";
  169.             curStat = "MM_displayStatusMsg('" + statMsg + "');";
  170.             javaScript += curStat;
  171.             stat = true;
  172.             continue;
  173.         }
  174.         if (curBehavior.action == kActionSwapImageRestore) {
  175.             swapRestore = true;
  176.             continue;
  177.         }
  178.         
  179.         if (curBehavior.action == kActionButtonRestore) {
  180.             buttonRestore = true;
  181.             continue;
  182.         }
  183.         
  184.         var swapRow = curBehavior.targetRowNum;
  185.         var swapCol = curBehavior.targetColumnNum;
  186.         var swapFrame = curBehavior.targetFrameNum; 
  187.         var swapTable = curBehavior.targetTable;
  188.         var fileName;
  189.         if (!swapTable) {
  190.             /* Not a swap behavior, so continue. */
  191.             continue;
  192.         }
  193.  
  194.         if (curBehavior.hasHref) {
  195.             fileName = curBehavior.href;
  196.         } else {
  197.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  198.         }
  199.  
  200.  
  201.         var cellName = CellName(swapTable, swapRow,swapCol);
  202.         
  203.         // Translate button Behaviors into JavaScript.
  204.         if (curBehavior.action == kActionButtonDown) {
  205.             //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  206.             nbDown += "'" + cellName + "','" + fileName + "',";
  207.             if (curBehavior.preload) nbDownPreload = true;
  208.             continue;
  209.         }
  210.         // Translate button Behaviors into JavaScript.
  211.         if (curBehavior.action == kActionButtonHighlight) {
  212.             var highlightName = "";
  213.             if (curBehavior.downHighlight) {
  214.                 if (curBehavior.hasDhHref) {
  215.                     highlightName = curBehavior.dhHref;
  216.                 } else {
  217.                     var f = curBehavior.dhTargetFrameNum;
  218.                     highlightName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(f) + swapTable[swapRow][swapCol].imageSuffix
  219.                 }
  220.             }            
  221.             nbHighlight += "'" + cellName + "','" + fileName + "','" + highlightName +"',";
  222.             if (curBehavior.preload) nbHighlightPreload = true;
  223.             continue;
  224.         }
  225.         // Translate Swap Image Behaviors into JavaScript.
  226.         if (curBehavior.action == kActionSwapImage) {
  227.             swap += "'" +cellName +"','','" + fileName + "',";
  228.             continue;
  229.         }        
  230.     }
  231.     if (nbDown != "" &&  targetEvent == kEventOnLoad) {
  232.          // Eat it.  Special handling for this one.
  233.         nbDown = "";
  234.     }
  235.     if (nbDown != "") {
  236.         javaScript += "MM_nbGroup('down','navbar1'," + nbDown
  237.         if (nbDownPreload) {
  238.             javaScript += "1);";
  239.         } else {
  240.             javaScript += "0);";
  241.         }
  242.     }
  243.      if (nbHighlight != "") {
  244.         javaScript += "MM_nbGroup('over'," + nbHighlight
  245.         if (nbHighlightPreload) {
  246.             javaScript += "1);";
  247.         } else {
  248.             javaScript += "0);";
  249.         }
  250.     }
  251.     if (swap != "") {
  252.         javaScript += "MM_swapImage(" + swap + "1);";
  253.     }
  254.     if (swapRestore) {
  255.         javaScript += "MM_swapImgRestore();";
  256.     }
  257.     if (buttonRestore) {
  258.         javaScript += "MM_nbGroup('out');";
  259.     }
  260.     // Erase status bar message onMouseOut.
  261.     if (eraseStatOnMouseOut && targetEvent == kEventMouseOut) {
  262.         javaScript += "MM_displayStatusMsg(' ');" ;
  263.         stat = true;
  264.     }
  265.     
  266.     if (stat) javaScript += "return document.MM_returnValue";
  267.     return(javaScript);
  268. }
  269.  
  270. // Determine and process Behaviors in the document.
  271. function ProcessBehavior(theCurBehaviors) {
  272.     
  273.     javaOver = ProcessEvent(theCurBehaviors, kEventMouseOver);
  274.     javaOut = ProcessEvent(theCurBehaviors, kEventMouseOut);
  275.     javaClick = ProcessEvent(theCurBehaviors, kEventOnClick);
  276.     if (javaOver != "" || javaOut != "" || javaClick != "") {
  277.         return(true);
  278.     }
  279.     return(false);
  280. }
  281.  
  282. function NavLoadInit(theCurBehaviors, myCellName) {
  283.     // Declare variable for processing Behaviors.
  284.     var nbDown = "";
  285.     var nbDownPreload = false;
  286.     var javaScript = "";
  287.     // Translate Behaviors into JavaScript.
  288.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  289.         curBehavior = theCurBehaviors[i];
  290.         
  291.         if (curBehavior.ignoreFlag) continue;
  292.         
  293.         if (curBehavior.event != kEventOnLoad) continue;
  294.         
  295.         if (curBehavior.action != kActionButtonDown) {
  296.             continue;
  297.         }
  298.         
  299.         var swapRow = curBehavior.targetRowNum;
  300.         var swapCol = curBehavior.targetColumnNum;
  301.         var swapFrame = curBehavior.targetFrameNum; 
  302.         var swapTable = curBehavior.targetTable;
  303.         var fileName;
  304.         if (!swapTable) {
  305.             /* Not a swap behavior, so continue. */
  306.             continue;
  307.         }
  308.  
  309.         var cellName = CellName(swapTable, swapRow,swapCol);
  310.         if (cellName != myCellName) continue;
  311.         if (curBehavior.hasHref) {
  312.             fileName = curBehavior.href;
  313.         } else {
  314.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  315.         }
  316.         nbDown = fileName;
  317.      }
  318.  
  319.     return(nbDown);
  320. }
  321.  
  322. var filesToPreload = new Array;
  323. function PreloadFile(fileName) {
  324.     if (!fileName) return;
  325.     /* See if we already precached this one. */
  326.     for (j=0; j<filesToPreload.length; j++) {
  327.         if (filesToPreload[j] == fileName) {
  328.             return;
  329.         }
  330.     }
  331.     filesToPreload[j] = fileName;
  332. }
  333.  
  334. function DoPreload(curBeh, swapRow, swapCol, swapFrame, swapTable) {
  335.     var fileName;
  336.     var curFile;
  337.     var j;
  338.     if (curBeh.hasHref) {
  339.         fileName = curBeh.href;
  340.     } else {
  341.         curFile = swapTable[swapRow][swapCol].getFrameFileName(swapFrame);
  342.         if (curFile) 
  343.             fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  344.     }
  345.     PreloadFile(fileName);
  346.     if (curBeh.downHighlight) {
  347.         if (curBeh.hasDhHref) {
  348.             fileName = curBeh.dhHref;
  349.         } else {
  350.             var f = curBeh.dhTargetFrameNum;
  351.             curFile = swapTable[swapRow][swapCol].getFrameFileName(f);
  352.             if (curFile) {
  353.                 fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  354.             }
  355.         }
  356.         if (fileName) {
  357.             PreloadFile(fileName);
  358.         }
  359.     }
  360. }
  361.  
  362. function DoFile(curBeh) {
  363.     var swapRow = curBeh.targetRowNum;
  364.     var swapCol = curBeh.targetColumnNum;
  365.     var swapFrame = curBeh.targetFrameNum; 
  366.     var swapTable = curBeh.targetTable;
  367.     if (!swapTable) return;
  368.     var fileName = swapTable[swapRow][swapCol].getFrameFileName(0);
  369.     if (curBeh.downHighlight && curBeh.hasDhTargetFrame) {
  370.         var fm = curBeh.dhTargetFrameNum;
  371.         if (!swapTable[swapRow][swapCol].getFrameFileName(fm)) {
  372.             var tmp;
  373.             var frame = fm+1;
  374.             if (fm < 4) {
  375.                 tmp = fileName + sfx[fm];
  376.             } else {
  377.                 tmp = fileName + "_f" + frame;
  378.             }
  379.             swapTable[swapRow][swapCol].setFrameFileName(fm, tmp);
  380.         }
  381.     }
  382.     if (curBeh.preload) {
  383.         DoPreload(curBeh, swapRow, swapCol, swapFrame, swapTable);
  384.     }
  385.     if (curBeh.hasTargetFrame && swapFrame > 0) {
  386.         if (swapTable[swapRow][swapCol].getFrameFileName(swapFrame)) return;
  387.         var frame = swapFrame + 1;
  388.         if (swapFrame < 4) {
  389.             fileName = fileName + sfx[swapFrame];
  390.         } else {
  391.             fileName = fileName + "_f" + frame;
  392.         }
  393.         swapTable[swapRow][swapCol].setFrameFileName(swapFrame, fileName);
  394.     } 
  395. }
  396.  
  397. // Examine all behaviors to determine what actions are present. 
  398. // Determine which files to pre-cache.
  399. var FWLoadInit = "";
  400. function DoFileAndPreload(curSlices) {
  401.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  402.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  403.             if (curSlices[curRow][curCol].skipCell) continue;
  404.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  405.             if (nestedTable) {
  406.                 DoFileAndPreload(nestedTable);
  407.                 continue;
  408.             }
  409.             if (curSlices[curRow][curCol].behaviors.numberOfBehaviors > 0) {
  410.                 var behaviors = curSlices[curRow][curCol].behaviors;
  411.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  412.                     var curBehavior = behaviors[i];
  413.                     if (curBehavior.action == kActionSwapImage) {
  414.                         DoFile(curBehavior);
  415.                         hasSwap = true;
  416.                     }
  417.                     if (curBehavior.action == kActionButtonDown) {
  418.                         DoFile(curBehavior);
  419.                         hasDown = true;
  420.                     }
  421.                     if (curBehavior.action == kActionButtonHighlight) {
  422.                         DoFile(curBehavior);
  423.                         hasDown = true;
  424.                     }
  425.                     if (curBehavior.action == kActionButtonRestore) {
  426.                         DoFile(curBehavior);
  427.                         hasDown = true;
  428.                     }
  429.                     if (curBehavior.action == kActionSwapImageRestore) {
  430.                         hasRestore = true;
  431.                     }
  432.                     if (curBehavior.action == kActionStatusMessage) {
  433.                         hasStatusMessage = true;
  434.                     }
  435.                 }
  436.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  437.                 if (init != "") {
  438.                     FWLoadInit += init;
  439.                 }
  440.             }
  441.             var imagemap = curSlices[curRow][curCol].imagemap;
  442.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  443.                 var curImagemap = imagemap[j];
  444.                 var behaviors = curImagemap.behaviors;
  445.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  446.                     var curBehavior = behaviors[i];
  447.                     if (curBehavior.action == kActionSwapImage) {
  448.                         DoFile(curBehavior);
  449.                         hasSwap = true;
  450.                     }
  451.                     if (curBehavior.action == kActionButtonDown) {
  452.                         DoFile(curBehavior);
  453.                         hasDown = true;
  454.                     }
  455.                     if (curBehavior.action == kActionButtonHighlight) {
  456.                         DoFile(curBehavior);
  457.                         hasDown = true;
  458.                     }
  459.                     if (curBehavior.action == kActionButtonRestore) {
  460.                         DoFile(curBehavior);
  461.                         hasDown = true;
  462.                     }
  463.                     if (curBehavior.action == kActionSwapImageRestore) {
  464.                         hasRestore = true;
  465.                     }
  466.                     if (curBehavior.action == kActionStatusMessage) {
  467.                         hasStatusMessage = true;
  468.                     }
  469.                 }
  470.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  471.                 if (init != "") {
  472.                     FWLoadInit += init;
  473.                 }
  474.             }
  475.         }
  476.     }
  477. }
  478.  
  479. DoFileAndPreload(slices);
  480.     
  481. /*--------------------------  JavaScript functions used in the HTML -----------------*/
  482.  
  483.  
  484. // Write out only the JavaScript functions needed for the HTM
  485. if (doHeader) {
  486.     if (hasStatusMessage || hasDown || hasSwap || hasRestore || filesToPreload.length > 0) {
  487.         // Begin Script. Hide Script from non-javascript-enabled browsers.
  488.         WRITE_HTML("<script language=\"JavaScript\">\n");
  489.         WRITE_HTML("<!--hide this script from non-javascript-enabled browsers\n");
  490.         WRITE_HTML("\n");
  491.         // Write function dm if document includes status bar messages.
  492.         if (hasStatusMessage) {
  493.             WRITE_JS_COMMENT("Function that displays status bar messages.")
  494.             //WRITE_HTML(MM_displayStatusMsg);
  495.             WRITE_HTML("function MM_displayStatusMsg(msgStr)  { //v3.0\n");
  496.             WRITE_HTML("    status=msgStr; document.MM_returnValue = true;\n");
  497.             WRITE_HTML("}\n");
  498.             WRITE_HTML("\n");
  499.         }
  500.  
  501.  
  502.         if (hasDown || hasSwap) {
  503.             //WRITE_HTML(MM_findObj);
  504.             WRITE_HTML("function MM_findObj(n, d) { //v3.0\n");
  505.             WRITE_HTML("  var p,i,x;  if(!d) d=document; if((p=n.indexOf(\"?\"))>0&&parent.frames.length) {\n");
  506.             WRITE_HTML("    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}\n");
  507.             WRITE_HTML("  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];\n");
  508.             WRITE_HTML("  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;\n");
  509.             WRITE_HTML("}\n");
  510.  
  511.         }
  512.  
  513.         // Write function MM_swapImage if document includes swap image behaviors.
  514.         if (hasSwap) {
  515.             WRITE_JS_COMMENT("Functions that swaps images.")
  516.             //WRITE_HTML(MM_swapImage);
  517.             WRITE_HTML("function MM_swapImage() { //v3.0\n");
  518.             WRITE_HTML("  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)\n");
  519.             WRITE_HTML("   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}\n");
  520.             WRITE_HTML("}\n");
  521.  
  522.         }
  523.  
  524.         // Write function MM_swapImage if document includes swap image behaviors.
  525.         if (hasRestore) {
  526.             //WRITE_HTML(MM_swapImgRestore);    
  527.             WRITE_HTML("function MM_swapImgRestore() { //v3.0\n");
  528.             WRITE_HTML("  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;\n");
  529.             WRITE_HTML("}\n");
  530.             WRITE_HTML("\n");
  531.         }
  532.  
  533.         if (hasDown) {
  534.             WRITE_JS_COMMENT("Functions that swaps down images.")
  535.             //WRITE_HTML(MM_nbGroup);
  536.             WRITE_HTML("function MM_nbGroup(event, grpName) { //v3.0\n");
  537.             WRITE_HTML("  var i,img,nbArr,args=MM_nbGroup.arguments;\n");
  538.             WRITE_HTML("  if (event == \"init\" && args.length > 2) {\n");
  539.             WRITE_HTML("    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {\n");
  540.             WRITE_HTML("      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;\n");
  541.             WRITE_HTML("      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();\n");
  542.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  543.             WRITE_HTML("      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  544.             WRITE_HTML("        if (!img.MM_up) img.MM_up = img.src;\n");
  545.             WRITE_HTML("        img.src = img.MM_dn = args[i+1];\n");
  546.             WRITE_HTML("        nbArr[nbArr.length] = img;\n");
  547.             WRITE_HTML("    } }\n");
  548.             WRITE_HTML("  } else if (event == \"over\") {\n");
  549.             WRITE_HTML("    document.MM_nbOver = nbArr = new Array();\n");
  550.             WRITE_HTML("    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {\n");
  551.             WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  552.             WRITE_HTML("      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];\n");
  553.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  554.             WRITE_HTML("    }\n");
  555.             WRITE_HTML("  } else if (event == \"out\" ) {\n");
  556.             WRITE_HTML("    for (i=0; i < document.MM_nbOver.length; i++) {\n");
  557.             WRITE_HTML("      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }\n");
  558.             WRITE_HTML("  } else if (event == \"down\") {\n");
  559.             WRITE_HTML("    if ((nbArr = document[grpName]) != null)\n");
  560.             WRITE_HTML("      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }\n");
  561.             WRITE_HTML("    document[grpName] = nbArr = new Array();\n");
  562.             WRITE_HTML("    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  563.             WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  564.             WRITE_HTML("      img.src = img.MM_dn = args[i+1];\n");
  565.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  566.             WRITE_HTML("  } }\n");
  567.             WRITE_HTML("}\n");
  568.             WRITE_HTML("\n");
  569.         }
  570.  
  571.  
  572.         if (filesToPreload.length > 0) {
  573.             WRITE_JS_COMMENT("Functions that handle preload.")
  574.             //WRITE_HTML(MM_preloadImages);
  575.             WRITE_HTML("function MM_preloadImages() { //v3.0\n");
  576.             WRITE_HTML(" var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();\n");
  577.             WRITE_HTML("   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)\n");
  578.             WRITE_HTML("   if (a[i].indexOf(\"#\")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}\n");
  579.             WRITE_HTML("}\n");
  580.             WRITE_HTML("\n");
  581.         }
  582.  
  583.         // Stop hiding script from non-javascript-enabled browsers. End script.
  584.         WRITE_HTML("// stop hiding -->\n");      
  585.         WRITE_HTML("</script>\n");
  586.         WRITE_HTML("\n");
  587.     }
  588.  /*----------------- END JavaScript functions used in the HTML -----------------*/
  589.  
  590.     // Close head tag.
  591.     WRITE_HTML("</head>\n");      
  592.  
  593.     // Begin body tag. Set background color to Fireworks document canvas color.
  594.     WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor.toString(16), "\"");
  595.  
  596.     // Write onLoad function.
  597.         if (FWLoadInit || filesToPreload.length>0) {
  598.             WRITE_HTML(" onLoad=\"");
  599.             WRITE_HTML(FWLoadInit);
  600.             var i;
  601.             for (i=0; i<filesToPreload.length; i++) {
  602.                 if (i==0) WRITE_HTML("MM_preloadImages(");
  603.                 else WRITE_HTML(",");
  604.                 WRITE_HTML("'" + filesToPreload[i] + "'");
  605.             }
  606.             if (i>0) WRITE_HTML(");");
  607.             WRITE_HTML("\"");
  608.         }
  609.         WRITE_HTML(">\n");    // close the body tag.
  610.         WRITE_HTML("\n");
  611.         
  612. }    
  613.           
  614.  
  615. // Write comment for start of table copy/paste section.
  616. var needTable = slices.numRows > 1 || slices.numColumns > 1;
  617. if (needTable) {
  618.     WRITE_HTML_COMMENT("The following section is an HTML table which reassembles the sliced image in a browser.");
  619.     WRITE_HTML_COMMENT("Copy the table section including the opening and closing table tags, and paste the data where");
  620.     WRITE_HTML_COMMENT("you want the reassembled image to appear in the destination document. ");
  621.     WRITE_HTML("\n");
  622. }
  623. WRITE_HTML_COMMENT("------------------------ BEGIN COPYING THE HTML HERE --------------------------");
  624.  
  625. if (needTable) WRITE_HTML_COMMENT(" Image with table ");
  626.  
  627. function WriteTable(curSlices, indent) {
  628.     var needTable = curSlices.numRows > 1 || curSlices.numColumns > 1;
  629.     var curCol;
  630.     var curRow;
  631.     var downIndex = 0;
  632.     if (needTable) {
  633.         WRITE_HTML("<table ");
  634.  
  635.         // If the Fireworks document's canvas is not transparent and the Include undefined curSlices checkbox
  636.         // is off, give the table a background color based on the FIreworks document's canvas color.
  637.         if (!exportDoc.backgroundIsTransparent && curSlices.doSkipUndefined) {
  638.             WRITE_HTML("bgcolor=\"#", exportDoc.backgroundColor, "\" ");
  639.         } 
  640.  
  641.         WRITE_HTML("border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"",
  642.                 curSlices.width, "\">\n");
  643.  
  644.         /* This is the magic comment for html update. */
  645.         if (indent == "") {
  646.             //<--- fwtable fwsrc="mydoc" fwbase="basename" --->
  647.             var comment = "<!-- fwtable fwsrc=\"" + exportDoc.docSaveName + "\" fwbase=\"" + exportDoc.filename + "\"" + " -->\n";
  648.             WRITE_HTML(comment);
  649.         }
  650.  
  651.  
  652.         
  653.     // If shims have been specified, write shim row.    
  654.         if (curSlices.doShimEdges) {
  655.             WRITE_HTML(indent+"  <tr>\n");
  656.             WRITE_HTML_COMMENT(" Shim row, height 1. ");
  657.             for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  658.                 WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"", 
  659.                     curSlices[0][curCol].cellWidth, "\" height=\"1\" border=\"0\"></td>\n"); 
  660.             }
  661.             WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"1", 
  662.                 "\" height=\"1\" border=\"0\"></td>\n"); 
  663.             WRITE_HTML(indent+"  </tr>\n");
  664.             WRITE_HTML("\n");
  665.         }
  666.     }
  667.     // Write table rows.
  668.     for (curRow = 0; curRow < curSlices.numRows; curRow++) {
  669.         if (needTable) {
  670.             WRITE_HTML(indent+"  <tr valign=\"top\">");
  671.             WRITE_HTML_COMMENT(" row "+(curRow+1)+" ");
  672.             if (!doComments) WRITE_HTML("\n");
  673.         }
  674.         for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  675.             var curSlice = curSlices[curRow][curCol];
  676.             if (curSlice.skipCell) continue; 
  677.  
  678.             if (needTable) {
  679.                 // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  680.                 WRITE_HTML(indent+"   <td");
  681.                 if (curSlice.rowSpan > 1) {
  682.                     WRITE_HTML(" rowspan=\"", curSlice.rowSpan,"\"");
  683.                 }
  684.                 if (curSlice.columnSpan>1) {
  685.                     WRITE_HTML(" colspan=\"", curSlice.columnSpan, "\"");
  686.                 }
  687.                 WRITE_HTML(">");
  688.             }
  689.  
  690.             var nestedTable = curSlice.nestedTableSlices;
  691.             if (nestedTable) {
  692.                 WriteTable(nestedTable, "    "+indent);
  693.                 if (needTable) {
  694.                     WRITE_HTML("</td>");
  695.                 }
  696.                 WRITE_HTML("\n");
  697.                 continue;
  698.             }
  699.  
  700.             // Write HTML text from curSlices set to "Text (No Image)"
  701.             if (!curSlice.hasImage) {
  702.                 // no image, just dump out html text.
  703.                 if (curSlice.htmlText) {
  704.                     WRITE_HTML(curSlice.htmlText);
  705.                 } else if (needTable) {
  706.                     if (curSlices.shimPath) {
  707.                         WRITE_HTML("<img src=\"",
  708.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  709.                             curSlice.height, "\" border=\"0\">");
  710.                     } 
  711.                 }
  712.                 if (needTable) WRITE_HTML("</td>\n");
  713.                 continue;
  714.             }
  715.  
  716.             // If current slice is not defined by a slice object and Export Undefined
  717.             // curSlices is not checked, don't output an image and if Shims are specified 
  718.             // place a shim image in the current cel
  719.             if (curSlice.isUndefined && curSlices.doSkipUndefined) {
  720.                 if (needTable) {
  721.                     if (curSlices.shimPath) {
  722.                         WRITE_HTML("<img src=\"",
  723.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  724.                             curSlice.height, "\" border=\"0\">");
  725.                     } 
  726.                     WRITE_HTML("</td>\n");
  727.                 }
  728.                 // Tell Fireworks to not write the image file. Setting the filename to "" forces 
  729.                 // Fireworks to not generate the image.
  730.                 var q;
  731.                 for (q=0; q<exportDoc.numFrames; q++) {
  732.                     curSlice.setFrameFileName(q, "");
  733.                 }    
  734.                 continue;
  735.             }
  736.  
  737.             // Write link if slice has URL attached.
  738.             var href = "href=\"#\"";
  739.             var hasHref = curSlice.hasHref;
  740.             var abortHref = false;
  741.             if (curSlice.hasHref) {
  742.                 href = "href=\"";
  743.                 href += curSlice.href;
  744.                 href += "\"";
  745.                 if (curSlice.hasTargetText) {
  746.                     href += " target=\"";
  747.                     href += curSlice.targetText;
  748.                     href += "\"";
  749.                 }
  750.                 
  751.             } else {
  752.                 var link = "";
  753.                 if (exportDoc.backgroundLink) {
  754.                     link = exportDoc.backgroundLink.href;
  755.                 }
  756.                 if (link != "") {
  757.                     hasHref = true;
  758.                     href = "href=\"" + link +"\"";
  759.                 }
  760.             }
  761.  
  762.             if (slices.doDemoHTML && curSlice.downIndex>0) {
  763.                 href = "href=\"" + slices.demoHref(curSlice.downIndex) +".htm\"";
  764.             }
  765.  
  766.             var cellName = CellName(curSlices, curRow, curCol);
  767.             var anchorTagOpen = false;
  768.  
  769.             // If the slice has image map hotspots and has a url attached to it,
  770.             // ignore the url here and move it into the image map.
  771.             if (curSlice.hasImage && curSlice.hasImagemap) {
  772.                 abortHref = true;  // we will put the href in the imagemaps.
  773.             }
  774.  
  775.             // Write rollover and swap image events.
  776.             if (!abortHref) {
  777.                 var behaviors = curSlice.behaviors;
  778.                 var gotJavascript = ProcessBehavior(behaviors);
  779.  
  780.                 if ( gotJavascript || hasHref) {
  781.                       WRITE_HTML("<a ");
  782.                     anchorTagOpen = true;
  783.                     WRITE_HTML(href);
  784.  
  785.                     if (javaOut != "") {
  786.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  787.                     }
  788.                     if (javaOver != "") {
  789.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  790.                     }
  791.                     if (javaClick != "") {
  792.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  793.                     }
  794.                     WRITE_HTML(">");
  795.                 }
  796.             }
  797.  
  798.             // Place image.
  799.             if (curSlice.hasImage) {
  800.                 var imageName = curSlice.getFrameFileName(0); 
  801.                 if (slices.doDemoHTML && slices.demoIndex>0 && 
  802.                     slices.demoIndex == curSlice.downIndex) {
  803.                     imageName = curSlice.getFrameFileName(2);
  804.                 } 
  805.                 var altText = "";
  806.                 if (curSlice.hasAltText) {
  807.                     altText = curSlice.altText;
  808.                 } else {
  809.                     altText = exportDoc.altText;
  810.                 }
  811.                 var btnDownSrc = NavLoadInit(curSlice.behaviors, cellName);
  812.                 var btnInitSrc = "";
  813.                     //onLoad="MM_nbGroup('init','navbar1','imgName','down.gif','img2Name','down',1)"
  814.                 var src = curSlices.imagesDirPath + imageName + curSlice.imageSuffix;
  815.                 if (btnDownSrc) {
  816.                     btnInitSrc = src;
  817.                     src = btnDownSrc;    
  818.                 }
  819.  
  820.                 // Assemble info for image tag.
  821.                 // Ex: <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  822.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  823.                     src, "\" width=\"",
  824.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  825.                 
  826.                 // Write image map name.
  827.                 // Ex: usemap="#base_r1_c2"
  828.                 if (curSlice.hasImagemap) {     
  829.                     WRITE_HTML(" usemap=\"#m_", imageName, "\""); 
  830.                 }
  831.                 
  832.                 // Write alt text.
  833.                 if (altText != "") {
  834.                     WRITE_HTML(" alt=\"", altText, "\"");
  835.                 }
  836.                 var btnDown = "";
  837.                 if (btnInitSrc) {
  838.                     //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  839.                     btnDown = " '" + cellName + "','" + btnInitSrc + "',";
  840.                      btnDown = "onLoad=\"MM_nbGroup('init','navbar1'," + btnDown
  841.                     btnDown += "1)\"";
  842.                 }
  843.  
  844.                 if (btnDown) WRITE_HTML(btnDown);
  845.                 WRITE_HTML(">");    
  846.             }
  847.  
  848.             if (anchorTagOpen) {
  849.                 WRITE_HTML("</a>");    
  850.             }
  851.             if (needTable) WRITE_HTML("</td>\n");    
  852.         }
  853.         
  854.         if (needTable) {
  855.             // Place shim in rightmost column of table.
  856.             if (curSlices.doShimEdges) {
  857.                 /* Write the 1 pixel transparent shim. */
  858.                 WRITE_HTML("   <td><img src=\"",
  859.                     curSlices.shimPath, "\" width=\"1\" height=\"", 
  860.                     curSlices[curRow][0].cellHeight, "\" border=\"0\"></td>\n"); 
  861.             }
  862.             WRITE_HTML(indent+"  </tr>\n");
  863.         }
  864.     }        
  865.     if (needTable) {
  866.         // Close table.
  867.         if (indent!="") WRITE_HTML(indent+"</table>");
  868.     }
  869. }
  870.  
  871. function WriteImagemaps(curSlices, indent) {
  872.     // Traverse all curSlices and generate any image maps needed.
  873.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  874.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  875.             var curSlice = curSlices[curRow][curCol];
  876.             if (curSlice.skipCell) continue; 
  877.             var nestedTable = curSlice.nestedTableSlices;
  878.             if (nestedTable) {
  879.                 WriteImagemaps(nestedTable, "    "+indent);
  880.                 continue;
  881.             }
  882.             if (curSlice.hasImagemap) {
  883.                 
  884.                 // Write the image map.
  885.                 WRITE_HTML(indent+"<map name=\"m_", curSlice.getFrameFileName(0), "\">\n");
  886.  
  887.                 var i = 0;
  888.                 var imagemap = curSlice.imagemap;
  889.                 while (i < imagemap.numberOfURLs) {
  890.                     var curImagemap = imagemap[i];
  891.  
  892.                     var behaviors = curImagemap.behaviors;
  893.  
  894.                     if (behaviors.numberOfBehaviors==0) {
  895.                         var behaviors = curSlice.behaviors;
  896.                     }
  897.                      javaOver = "";
  898.                     javaOut = "";
  899.                     javaClick = "";
  900.                     var gotJavascript = ProcessBehavior(behaviors);
  901.     
  902.                     // Write the area tag with shape definitions.
  903.                     WRITE_HTML(indent+"<area shape=\"");
  904.                     WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  905.                     WRITE_HTML("\" coords=\"");
  906.                     for (var j=0; j<curImagemap.numCoords; j++) {
  907.                         if (j>0) WRITE_HTML(",");
  908.                         // polygon has n coords.
  909.                         // rect has 2 coords, topLeft, and botomRight.
  910.                         // circle has one coord, center; plus radius.
  911.                         WRITE_HTML((curImagemap.xCoord(j)-curSlice.left), ",", (curImagemap.yCoord(j)-curSlice.top)); 
  912.                     }
  913.                     if (curImagemap.shape == "circle") {
  914.                         // Write the radius for circle hotspots.
  915.                         WRITE_HTML(", ", curImagemap.radius);
  916.                     }
  917.                     WRITE_HTML("\"");
  918.                     var href = " href=\"#\"";
  919.                     if (curImagemap.hasHref) {
  920.                         href = " href=\"";
  921.                         href += curImagemap.href;
  922.                         href += "\"";
  923.                         if (curImagemap.hasTargetText) {
  924.                             href += " target=\"";
  925.                             href += curImagemap.targetText;
  926.                             href += "\"";
  927.                         }
  928.                     }
  929.  
  930.                     WRITE_HTML(href);
  931.                     
  932.                     // Write alt text for hotspot.
  933.                     var altText = "";
  934.                     if (curImagemap.hasAltText) {
  935.                         altText = curImagemap.altText;
  936.                     } else {
  937.                         altText = exportDoc.altText;
  938.                     }
  939.  
  940.                     if (altText!="") {
  941.                         WRITE_HTML(" title=\"", altText, "\"");
  942.                         WRITE_HTML(" alt=\"", altText, "\"");
  943.                     }
  944.  
  945.                     // Write rollover and swap image behaviors.
  946.                     if (javaOut != "") {
  947.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  948.                     }
  949.                     if (javaOver != "") {
  950.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  951.                     }
  952.                     if (javaClick != "") {
  953.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  954.                     }
  955.  
  956.                     WRITE_HTML(" >\n");
  957.                     i++;
  958.                 } 
  959.                 var behaviors = curSlices[curRow][curCol].behaviors;
  960.                  javaOver = "";
  961.                 javaOut = "";
  962.                 javaClick = "";
  963.                 var gotJavascript = ProcessBehavior(behaviors);
  964.                 
  965.                 var link = "";
  966.                 if (curSlice.hasHref) {
  967.                     link = curSlice.href;
  968.                 } else {  
  969.                     if (exportDoc.backgroundLink) {
  970.                         link = exportDoc.backgroundLink.href;
  971.                     }
  972.                 }
  973.  
  974.                 // If the current slice had a URL attached, it was moved and written here.
  975.                 if (gotJavascript || link != "") {
  976.                     WRITE_HTML(indent+"<area shape=\"rect\" coords=\"0,0, ", curSlice.width, ",", curSlice.height, "\" ");
  977.                     var href="#";
  978.                     if (link!="") {
  979.                         href = link;
  980.                     }
  981.                     WRITE_HTML("href=\"", href, "\"");
  982.  
  983.                     if (curSlice.hasTargetText) {
  984.                         WRITE_HTML("\n  target=\"", curSlices[curRow][curCol].targetText, "\"");
  985.                     }
  986.                     if (javaOut != "") {
  987.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  988.                     }
  989.                     if (javaOver != "") {
  990.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  991.                     }
  992.                     if (javaClick != "") {
  993.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  994.                     }
  995.                     var altText = "";
  996.                     if (curSlice.hasAltText) {
  997.                         altText = curSlice.altText;
  998.                     } else {
  999.                         altText = exportDoc.altText;
  1000.                     }
  1001.                     if (altText!="") {
  1002.                         WRITE_HTML(" title=\"", altText, "\"");
  1003.                         WRITE_HTML(" alt=\"", altText, "\"");
  1004.                     }
  1005.                     WRITE_HTML(">\n");
  1006.                 }    
  1007.  
  1008.                 WRITE_HTML(indent+"</map>\n")
  1009.                 WRITE_HTML("\n");
  1010.             }
  1011.         }
  1012.     }
  1013. }
  1014.  
  1015. WriteTable(slices, "");
  1016. WriteImagemaps(slices, "");
  1017.  
  1018. // End table copy/paste section.
  1019. if (needTable) {
  1020.     WRITE_HTML_COMMENT("   This table was automatically created with Macromedia Fireworks 3.0   ");
  1021.     WRITE_HTML_COMMENT("   http://www.macromedia.com   ");
  1022. }
  1023. WRITE_HTML("\n");
  1024. if (needTable) {
  1025.     WRITE_HTML("</table>\n");
  1026. }
  1027.  
  1028. WRITE_HTML_COMMENT("------------------------- STOP COPYING THE HTML HERE -------------------------");
  1029. if (doHeader) {
  1030.     WRITE_HTML("\n");
  1031.     WRITE_HTML("</body>\n");
  1032.  
  1033.     WRITE_HTML("\n");
  1034.     WRITE_HTML("</html>\n");
  1035.     WRITE_HTML("\n");
  1036. }
  1037.